﻿using Microsoft.AspNetCore.Mvc.ModelBinding;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace WebApplication1.Models
{
    public class Employee
    {
        public int Id { get; set; }

        [Display(Name = "姓名")]
        [Required(ErrorMessage = "{0}不能为空")]
        public string EmployeeName { get; set; }

        [Display(Name = "详细地址")]
        public string Address { get; set; }

        [Display(Name = "出生年月")]
        [DataType(DataType.Date, ErrorMessage = "出生年月格式不正确!")]
        public DateTime? BirthDate { get; set; }

        [Display(Name = "手机号码")]
        public string Phone { get; set; }

        [Display(Name = "邮箱")]
        public string Email { get; set; }

        [Display(Name = "薪资")]
        public decimal Salary { get; set; }

        [BindNever]
        public bool IsAdmin { get; set; }

        public List<Department> Departments { get; set; } = new List<Department>()
        {
            new Department(){ Id=1,Name="部门一" },
             new Department(){ Id=2,Name="部门二" },
        };

    }

    public class Department
    {
        public int Id { get; set; }

        public string Name { get; set; }
    }
}
